package com.monkeygroup.mygoplus.common.utils;

import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;


import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.monkeygroup.mygoplus.commit.thing.vo.PropertyCommitVO;
import com.monkeygroup.mygoplus.commit.user.vo.AutoLoginCommitVO;
import com.monkeygroup.mygoplus.user.vo.IdentifyVO;
import com.monkeygroup.mygoplus.user.vo.LoginResultVO;
import com.monkeygroup.mygoplus.user.vo.PersonalNomalInfo;
import com.monkeygroup.mygoplus.user.vo.UserCollectVO;


import java.util.ArrayList;
import java.util.List;

/**
 * 本地保存
 */
public class LocalInfo {


    public static boolean isLogin(Context context) {
    	
        SharedPreferences sh = Tools.getSharePreferences(context, "localfinfo");
        boolean flag = sh.contains("userid");
        return flag;
        
    }
    //登录次数
    public static String getLoginCount(Context context,String bank) {

        SharedPreferences sh = Tools.getSharePreferences(context, "LoginCount");
        String count = sh.getString(bank, null);
        return count;

    }
    //保存登录次数
    public static void saveLoginCount(Context context,String bank,String count) {

        SharedPreferences sh = Tools.getSharePreferences(context, "LoginCount");
        SharedPreferences.Editor editor = sh.edit();
        if(Integer.parseInt(count)<3){
            editor.putString(bank,String.valueOf(Integer.parseInt(count)+1) );
        }
        else{
            editor.putString(bank,"3");
        }
        editor.commit();
    }
    
    public static SharedPreferences getSharePreferences(Context context,
			String name) {
		SharedPreferences sh = context.getSharedPreferences(name,
				Context.MODE_PRIVATE);
		return sh;
	}

    public static String getUserID(Context context) {
        SharedPreferences sh = Tools.getSharePreferences(context, "localfinfo");
        String userid = sh.getString("userid", null);
        return userid;
    }

    //保存消息数目
    public static void saveNoticeCount(Context context,int count){
    	
    	SharedPreferences sh = Tools.getSharePreferences(context, "noticecount");
        SharedPreferences.Editor editor = sh.edit();
    	
        editor.putInt("noticecount", count);
                  

        editor.commit();
    	
    }
    
    //得到消息数目
    public static int getNoticeCount(Context context) {
	        SharedPreferences sh = Tools.getSharePreferences(context, "noticecount");
	        int count = sh.getInt("noticecount", 1);
	        return count;

	    }
    
    
    //判断是否初始化
    public static void saveIsInit(Context context){
    	
    	SharedPreferences sh = Tools.getSharePreferences(context, "isinit");
        SharedPreferences.Editor editor = sh.edit();
    	
        editor.putString("isinit", "init");
                  

		          
        editor.commit();
    	
    }
    
    //得到初始化状态
    public static String getInitState(Context context) {
        SharedPreferences sh = Tools.getSharePreferences(context, "localfinfo");
        String isinit = sh.getString("isinit", "");
        return isinit;

    }
    
    
    		
    
    /**
     * 注销当前用户
     *
     * @param context
     */
    public static void Logout(Context context) {
        SharedPreferences sh = Tools.getSharePreferences(context, "localfinfo");
        SharedPreferences.Editor editor = sh.edit();
        editor.remove("userid");
        editor.remove("pwd");
        editor.commit();
    }

    public static String getPhone(Context context) {
        SharedPreferences sh = Tools.getSharePreferences(context, "localfinfo");
        String phone = sh.getString("phone", "");
        return phone;

    }

    public static void saveLoginInfo(Context context,PersonalNomalInfo vo) {
	    SharedPreferences sh = Tools.getSharePreferences(context, "logininfo");
	        SharedPreferences.Editor editor = sh.edit();
	    
	    if (vo == null) {
          
		    editor.remove("name");
            editor.remove("password");


        }
        else{

            if(vo.getName()!=null&&!"".equals(vo.getName())){

                editor.putString("name",vo.getName());
            }
            if(vo.getPassword()!=null&&!"".equals(vo.getPassword())){
                editor.putString("password",vo.getPassword());
            }

        }

        editor.commit();
    }

    public static PersonalNomalInfo getLoginInfo(Context context) {


        PersonalNomalInfo user = new PersonalNomalInfo();
        SharedPreferences sh = Tools.getSharePreferences(context, "logininfo");


        String name = sh.getString("name", "");

        user.setName(name);
        String password = sh.getString("password", "");
        user.setPassword(password);


        return user;

    }


    //用户信息
    public static void saveUserInfo(Context context, PersonalNomalInfo vo){

	    
	    SharedPreferences sh = Tools.getSharePreferences(context, "localfinfo");
	        SharedPreferences.Editor editor = sh.edit();
        if (vo == null) {
      	  
      	  editor.remove("name");
            editor.remove("birthday");
            editor.remove("mobile");
            editor.remove("userName");
            editor.remove("password");
            editor.remove("headIcon");
            editor.remove("seq");
            editor.remove("account");
            editor.remove("background");
        }
        else{
           if(vo.getName()!=null){
               Log.e("保存====",""+vo.getName());
               editor.putString("name",vo.getName());
           }
            if(vo.getUserName()!=null){
                editor.putString("userName",vo.getUserName());
            }

            if(vo.getBirthday()!=null){
                editor.putString("birthday",vo.getBirthday());
            }

            if(vo.getGender()!=null){
                editor.putString("gender",vo.getGender());
            }

            if(vo.getMobile()!=null){
                editor.putString("mobile",vo.getMobile());
            }
            if(vo.getSeq()!=0){
                editor.putString("seq",String.valueOf(vo.getSeq()));
            }

            if(vo.getPassword()!=null){
                editor.putString("password",vo.getPassword());
            }
            if(vo.getHeadIcon()!=null){
                editor.putString("headIcon",vo.getHeadIcon());
            }
            if(vo.getAccount()!=null){
                editor.putString("account",vo.getAccount());
            }
            if(vo.getBackground()!=null){
                editor.putString("backgroud",vo.getBackground());
            }
//            if(vo.get()!=null){
//                editor.putString("password",vo.getPassword());
//            }




        }

        editor.commit();
    }
    //得到用户信息
    public static PersonalNomalInfo getUserInfo(Context context){

        PersonalNomalInfo user = new PersonalNomalInfo();

        SharedPreferences sh = Tools.getSharePreferences(context, "localfinfo");
        String name = sh.getString("name", "");
        user.setName(name);
        String userNmae = sh.getString("userName", "");
        user.setUserName(name);
        String birthday = sh.getString("birthday", "");
        user.setBirthday(birthday);
        String gender = sh.getString("gender", "");
        user.setGender(gender);
        String mobile = sh.getString("mobile", "");
        user.setMobile(mobile);
        String password = sh.getString("password", "");
        user.setPassword(password);
        String headIcon = sh.getString("headIcon", "");
        user.setHeadIcon(headIcon);
        String seq = sh.getString("seq", "");
        if(!StringUtil.isBlank(seq)){
            user.setSeq(Integer.parseInt(seq));
        }
        String account = sh.getString("account", "");
        user.setAccount(account);
        String background = sh.getString("background", "");
        user.setBackground(background);


        return user;
    }


    public static AutoLoginCommitVO getAutoLoginVO(Context context) {

        AutoLoginCommitVO vo =new AutoLoginCommitVO();

        SharedPreferences sh = Tools.getSharePreferences(context, "localfinfo");
        String phone = sh.getString("phone", "");
        String password = sh.getString("pwd", "");



        
        return vo;
    }

    //物件信息
    public static void saveProperty(Context context,PropertyCommitVO property){

        SharedPreferences sh = null;
        Log.e("saveProperty==",""+property.getProperty_purpose()+property.getProperty_modal()+"property");
        //車位
        if("carport".equals(property.getProperty_purpose())){
            sh = Tools.getSharePreferences(context, property.getProperty_purpose()+property.getProperty_carportmodal()+property.getProperty_carporttype()+"property");
        }
        else{
            sh = Tools.getSharePreferences(context, property.getProperty_purpose()+property.getProperty_modal()+"property");
        }
        SharedPreferences.Editor editor = saveVO(sh,property);

        editor.commit();
    }

    //移除物件信息
    public static void removeProperty(Context context,PropertyCommitVO property){
        //清空文件
        SharedPreferences sh = Tools.getSharePreferences(context, property.getProperty_purpose()+property.getProperty_modal()+"property");
        if(sh!=null) {
            sh.edit().clear().commit();
        }
    }



    //得到用户收藏信息
    public static UserCollectVO getUserCollectInfo(Context context,String mobile){

        UserCollectVO vo = new UserCollectVO();
        SharedPreferences sh = Tools.getSharePreferences(context, mobile+"usercollect");

        String phone = sh.getString("phone", "");
        vo.setPhone(phone);
        String collectSeq = sh.getString("collectSeq", "");
        vo.setCollectSeq(collectSeq);

        if(StringUtil.isBlank(collectSeq)){
            return null;
        }
        return vo;
    }

    //保存用户收藏信息
    public static void saveUserCollectInfo(Context context,UserCollectVO vo){
        SharedPreferences sh = Tools.getSharePreferences(context, vo.getPhone()+"usercollect");
        SharedPreferences.Editor editor = sh.edit();

        String phone = sh.getString("phone", "");
        String collectSeq = sh.getString("collectSeq", "");
        if(StringUtil.isBlank(phone)){
            editor.putString("phone",vo.getPhone());
            editor.putString("collectSeq",vo.getCollectSeq());
        }
        else{
            editor.putString("collectSeq",collectSeq+","+vo.getCollectSeq());
        }

        editor.commit();
    }
    //物件信息
    public static void saveRentProperty(Context context,PropertyCommitVO property){

        SharedPreferences sh = null;
        //車位
        if("carport".equals(property.getProperty_purpose())){
            sh = Tools.getSharePreferences(context, "rent"+property.getProperty_purpose()+property.getProperty_carportmodal()+property.getProperty_carporttype()+"property");
        }
        else{
            sh = Tools.getSharePreferences(context, "rent"+property.getProperty_purpose()+property.getProperty_modal()+"property");
        }
        SharedPreferences.Editor editor = saveVO(sh,property);

        editor.commit();
    }

    private static SharedPreferences.Editor saveVO(SharedPreferences sh,PropertyCommitVO property){
        SharedPreferences.Editor editor = sh.edit();
        editor.putString("property_purpose", property.getProperty_purpose());
        editor.putString("property_name", property.getProperty_name());
        editor.putString("property_hidegate", ""+property.getProperty_hidegate());
        //  editor.putString("et_addr", ""+property.get);

        editor.putString("property_alley", ""+property.getProperty_alley());
        editor.putString("property_gate", ""+property.getProperty_gate());
        editor.putString("property_lane", ""+property.getProperty_lane());
        //   editor.putString("property_lane", ""+property.getProperty_lane());
        editor.putString("property_storey", ""+property.getProperty_floor());
        editor.putString("property_offices", ""+property.getProperty_offices());
        editor.putString("property_floor", ""+property.getProperty_floor());
        editor.putString("property_room", ""+property.getProperty_room());
        editor.putString("property_width", ""+property.getProperty_width());
        editor.putString("property_height", ""+property.getProperty_height());


        editor.putString("property_equipment", ""+property.getProperty_equipment());


        //社區編號
        editor.putString("property_community", ""+property.getProperty_community());
        editor.putString("property_saleprice", ""+property.getProperty_saleprice());
        //1無 2 3 4 5 6 7 8
        editor.putString("property_fee", ""+property.getProperty_fee());
        editor.putString("property_feetype", ""+property.getProperty_feetype());
        editor.putString("property_minfloor", ""+property.getProperty_minfloor());
        editor.putString("property_totalfloor", ""+property.getProperty_totalfloor());
        //使用面积
        editor.putString("property_usearea", ""+property.getProperty_usearea());
        //物件面积
        editor.putString("property_ownershiparea", ""+property.getProperty_ownershiparea());
        //格局
        editor.putString("property_rooms", ""+property.getProperty_rooms());
        editor.putString("property_halls", ""+property.getProperty_halls());
        editor.putString("property_toilets", ""+property.getProperty_toilets());
        //  editor.putString("property_offices", ""+property.getProperty_offices());
        editor.putString("property_balconys", ""+property.getProperty_balconys());

        editor.putString("property_direction", ""+property.getProperty_direction());
        //屋齡
        editor.putString("property_completeyear", ""+property.getProperty_completeyear());
        editor.putString("property_completedate", ""+property.getProperty_completedate());

        editor.putString("property_fitting", ""+property.getProperty_fitting());
        editor.putString("property_layouttype", ""+property.getProperty_layouttype());

        editor.putString("property_desc", ""+property.getProperty_desc());

        editor.putString("property_lift", ""+property.getProperty_lift());
        //是否有車位
        editor.putString("property_carport", ""+property.getProperty_carport());
        //地址
        editor.putString("property_city", ""+property.getProperty_city());
        editor.putString("property_area", ""+property.getProperty_area());
        editor.putString("property_street", ""+property.getProperty_street());

        //提供設備
        editor.putString("property_shopequip", ""+property.getProperty_shopequip());
        //家具
        editor.putString("property_fitment", ""+property.getProperty_fitment());

        editor.putString("property_renttype", ""+property.getProperty_renttype());
        editor.putString("property_rentcontain", ""+property.getProperty_rentcontain());
        editor.putString("property_deposittype", ""+property.getProperty_deposittype());
        //段
        editor.putString("property_locate1", ""+property.getProperty_locate1());
        editor.putString("property_locate2", ""+property.getProperty_locate2());

        //土地屬性
        editor.putString("property_landapplication", ""+property.getProperty_landapplication());
        editor.putString("property_landattribute", ""+property.getProperty_landattribute());

        //图片
        if(property.getPropertyimg_sceimgtype()!=null && property.getPropertyimg_sceimgtype().length!=0){

            editor.putString("propertyimg_sceimgtype", ""+StringUtil.arrayToString(property.getPropertyimg_sceimgtype()));
        }
        //路徑
        editor.putString("propertyimg_path1",StringUtil.arrayToString(property.getPropertyimg_path1()));
        editor.putString("propertyimg_path2",StringUtil.arrayToString(property.getPropertyimg_path2()));
        editor.putString("propertyimg_path3",StringUtil.arrayToString(property.getPropertyimg_path3()));
        editor.putString("propertyimg_path4",StringUtil.arrayToString(property.getPropertyimg_path4()));
        editor.putString("propertyimg_path5",StringUtil.arrayToString(property.getPropertyimg_path5()));
        editor.putString("propertyimg_path6",StringUtil.arrayToString(property.getPropertyimg_path6()));
        editor.putString("propertyimg_path7",StringUtil.arrayToString(property.getPropertyimg_path7()));
        editor.putString("propertyimg_width",StringUtil.arrayToString(property.getPropertyimg_width()));
        editor.putString("propertyimg_height",StringUtil.arrayToString(property.getPropertyimg_height()));
        editor.putString("propertyimg_size",StringUtil.arrayToString(property.getPropertyimg_size()));
        editor.putString("propertyimg_name",StringUtil.arrayToString(property.getPropertyimg_name()));
        return editor;
    }

    //住宅
    public static PropertyCommitVO getHouseProperty(Context context,String modal){
        Log.e("getHouseProperty==",""+modal);
        SharedPreferences sh = Tools.getSharePreferences(context, "house"+modal+"property");
        PropertyCommitVO vo = getVO(sh);
        return vo;
    }

    public static PropertyCommitVO getShopProperty(Context context,String modal){
        SharedPreferences sh = Tools.getSharePreferences(context, "shop"+modal+"property");
        PropertyCommitVO vo = getVO(sh);
        return vo;
    }


    public static PropertyCommitVO getOfficeProperty(Context context,String modal){
        SharedPreferences sh = Tools.getSharePreferences(context, "office"+modal+"property");
        PropertyCommitVO vo = getVO(sh);
        return vo;
    }
    public static PropertyCommitVO getWorkshopProperty(Context context,String modal){
        SharedPreferences sh = Tools.getSharePreferences(context, "workshop"+modal+"property");
        PropertyCommitVO vo = getVO(sh);
        return vo;
    }

    public static PropertyCommitVO getLandProperty(Context context,String modal){
        SharedPreferences sh = Tools.getSharePreferences(context, "land"+modal+"property");
        PropertyCommitVO vo = getVO(sh);
        return vo;
    }

    public static PropertyCommitVO getCarportProperty(Context context,String modal,String type){
        SharedPreferences sh = Tools.getSharePreferences(context, "carport"+modal+type+"property");
        PropertyCommitVO vo = getVO(sh);
        return vo;
    }


    //出租住宅
    public static PropertyCommitVO getRentHouseProperty(Context context,String modal){
        SharedPreferences sh = Tools.getSharePreferences(context, "renthouse"+modal+"property");
        PropertyCommitVO vo = getVO(sh);
        return vo;
    }

    public static PropertyCommitVO getRentShopProperty(Context context,String modal){
        SharedPreferences sh = Tools.getSharePreferences(context, "rentshop"+modal+"property");
        PropertyCommitVO vo = getVO(sh);
        return vo;
    }


    public static PropertyCommitVO getRentOfficeProperty(Context context,String modal){
        SharedPreferences sh = Tools.getSharePreferences(context, "rentoffice"+modal+"property");
        PropertyCommitVO vo = getVO(sh);
        return vo;
    }
    public static PropertyCommitVO getRentWorkshopProperty(Context context,String modal){
        SharedPreferences sh = Tools.getSharePreferences(context, "rentworkshop"+modal+"property");
        PropertyCommitVO vo = getVO(sh);
        return vo;
    }

    public static PropertyCommitVO getRentLandProperty(Context context,String modal){
        SharedPreferences sh = Tools.getSharePreferences(context, "rentland"+modal+"property");
        PropertyCommitVO vo = getVO(sh);
        return vo;
    }

    public static PropertyCommitVO getRentCarportProperty(Context context,String modal,String type){
        SharedPreferences sh = Tools.getSharePreferences(context, "rentcarport"+modal+type+"property");
        PropertyCommitVO vo = getVO(sh);
        return vo;
    }


    private static PropertyCommitVO getVO(SharedPreferences sh){
        PropertyCommitVO vo =new PropertyCommitVO();
        String property_purpose = sh.getString("property_purpose", "");
        vo.setProperty_purpose(property_purpose);
        String name = sh.getString("property_name", "");
        vo.setProperty_name(name);
        String property_hidegate = sh.getString("property_hidegate", "");
        Log.e("property_hidegate===",""+property_hidegate);
        if(!StringUtil.isBlank(property_hidegate)){
            vo.setProperty_hidegate(Integer.parseInt(property_hidegate));
        }

        //是否有電梯
        String property_lift= sh.getString("property_lift", "");
        if(!StringUtil.isBlank(property_lift)){
            vo.setProperty_lift(Integer.parseInt(property_lift));
        }
        //是否有車位
        String property_carport= sh.getString("property_carport", "");
        if(!StringUtil.isBlank(property_lift)){
            vo.setProperty_carport(Integer.parseInt(property_carport));
        }
        //  editor.putString("et_addr", ""+property.get);

        String property_alley=sh.getString("property_alley", "");

        if(!StringUtil.isBlank(property_alley)){
            vo.setProperty_alley(Integer.parseInt(property_alley));
        }
        String property_gate = sh.getString("property_gate", "");
        if(!StringUtil.isBlank(property_gate)){
            vo.setProperty_gate(Integer.parseInt(property_gate));
        }
        String property_lane = sh.getString("property_lane", "");
        if(!StringUtil.isBlank(property_lane)){
            vo.setProperty_lane(Integer.parseInt(property_lane));
        }
        //   String property_lane = sh.getString("property_lane", "");

//      String property_storey= sh.getString("property_storey", "");
//        if(!StringUtil.isBlank(property_storey)){
//            vo.setProperty_(Integer.parseInt(property_storey));
//        }
        String property_offices = sh.getString("property_offices", "");
        if(!StringUtil.isBlank(property_offices)){
            vo.setProperty_offices(Integer.parseInt(property_offices));
        }
        //社區編號
        String property_community = sh.getString("property_community", "");
        if(!StringUtil.isBlank(property_community)){
            vo.setProperty_community(Integer.parseInt(property_community));
        }

        String property_saleprice = sh.getString("property_saleprice", "");
        if(!StringUtil.isBlank(property_saleprice)){
            vo.setProperty_saleprice(Integer.parseInt(property_saleprice));
        }

        //1無 2 3 4 5 6 7 8
        String property_fee = sh.getString("property_fee", "");
        if(!StringUtil.isBlank(property_fee)){
            vo.setProperty_fee(Integer.parseInt(property_fee));
        }
        String property_feetype = sh.getString("property_feetype", "");
        if(!StringUtil.isBlank(property_feetype)){
            vo.setProperty_feetype(Integer.parseInt(property_feetype));
        }

        //座向
        String property_direction = sh.getString("property_direction", "");
        if(!StringUtil.isBlank(property_direction)){
            vo.setProperty_direction(Integer.parseInt(property_direction));
        }
        String property_minfloor = sh.getString("property_minfloor", "");
        if(!StringUtil.isBlank(property_minfloor)){
            vo.setProperty_minfloor(Integer.parseInt(property_minfloor));
        }
        String property_totalfloor = sh.getString("property_totalfloor", "");
        if(!StringUtil.isBlank(property_totalfloor)){
            vo.setProperty_totalfloor(Integer.parseInt(property_totalfloor));
        }
        //使用面积
        String property_usearea = sh.getString("property_usearea", "");
        if(!StringUtil.isBlank(property_usearea)){
            vo.setProperty_usearea(Float.parseFloat(property_usearea));
        }
        String property_ownershiparea = sh.getString("property_ownershiparea", "");
        if(!StringUtil.isBlank(property_ownershiparea)){
            vo.setProperty_ownershiparea(Float.parseFloat(property_ownershiparea));
        }

        //格局
        String property_rooms = sh.getString("property_rooms", "");
        if(!StringUtil.isBlank(property_rooms)){
            vo.setProperty_rooms(Integer.parseInt(property_rooms));
        }
        String property_halls = sh.getString("property_halls", "");
        if(!StringUtil.isBlank(property_halls)){
            vo.setProperty_halls(Integer.parseInt(property_halls));
        }
        String property_toilets =sh.getString("property_toilets", "");
        if(!StringUtil.isBlank(property_toilets)){
            vo.setProperty_toilets(Integer.parseInt(property_toilets));
        }

        String property_floor =sh.getString("property_floor", "");
        if(!StringUtil.isBlank(property_floor)){
            vo.setProperty_floor(Integer.parseInt(property_floor));
        }
        String property_room =sh.getString("property_room", "");
        if(!StringUtil.isBlank(property_room)){
            vo.setProperty_room(Integer.parseInt(property_room));
        }

        // String property_offices = sh.getString("property_offices", "");
        String property_balconys=  sh.getString("property_balconys", "");
        if(!StringUtil.isBlank(property_balconys)){
            vo.setProperty_balconys(Integer.parseInt(property_balconys));
        }
        //屋齡
        String property_completeyear = sh.getString("property_completeyear", "");
        if(!StringUtil.isBlank(property_completeyear)){
            vo.setProperty_completeyear(Integer.parseInt(property_completeyear));
        }
        String property_completedate = sh.getString("property_completedate", "");
        if(!StringUtil.isBlank(property_completedate)){
            vo.setProperty_completedate(property_completedate);
        }
        String property_fitting = sh.getString("property_fitting", "");
        if(!StringUtil.isBlank(property_fitting)){
            vo.setProperty_fitting(Integer.parseInt(property_fitting));
        }
        String property_layouttype = sh.getString("property_layouttype", "");
        if(!StringUtil.isBlank(property_layouttype)){
            vo.setProperty_layouttype(property_layouttype);
        }
        String property_desc = sh.getString("property_desc", "");
        vo.setProperty_desc(property_desc);

        //地址
        String property_city = sh.getString("property_city", "");
        if(!StringUtil.isBlank(property_city)){
            vo.setProperty_city(Integer.parseInt(property_city));
        }

        String property_area = sh.getString("property_area", "");
        if(!StringUtil.isBlank(property_area)){
            vo.setProperty_area(Integer.parseInt(property_area));
        }
        String property_street = sh.getString("property_street", "");
        if(!StringUtil.isBlank(property_street)){
            vo.setProperty_street(property_street);
        }



        //長
        String property_width = sh.getString("property_width", "");
        if(!StringUtil.isBlank(property_width)){
            vo.setProperty_width(property_width);
        }
        //
        String property_height = sh.getString("property_height", "");
        if(!StringUtil.isBlank(property_height)){
            vo.setProperty_height(property_height);
        }

        //提供設備
        String property_shopequip = sh.getString("property_shopequip", "");
        if(!StringUtil.isBlank(property_shopequip)){
            vo.setProperty_shopequip(property_shopequip);
        }

        //提供設備
        String property_equipment = sh.getString("property_equipment", "");
        if(!StringUtil.isBlank(property_equipment)){
            vo.setProperty_equipment(property_equipment);
        }

        //家具
        String property_fitment = sh.getString("property_fitment", "");
        if(!StringUtil.isBlank(property_fitment)){
            vo.setProperty_fitment(property_fitment);
        }
        //
        String property_renttype = sh.getString("property_renttype", "");
        if(!StringUtil.isBlank(property_renttype)){
            vo.setProperty_renttype(Integer.parseInt(property_renttype));
        }

        //押金
        String property_deposittype = sh.getString("property_deposittype", "");
        if(!StringUtil.isBlank(property_deposittype)){
            vo.setProperty_deposittype(Integer.parseInt(property_deposittype));
        }
        //租金包含
        String property_rentcontain = sh.getString("property_rentcontain", "");
        if(!StringUtil.isBlank(property_rentcontain)){
            vo.setProperty_rentcontain(property_rentcontain);
        }
        //段
        String property_locate1 = sh.getString("property_locate1", "");
        if(!StringUtil.isBlank(property_locate1)){
            vo.setProperty_locate1(property_locate1);
        }
        String property_locate2 = sh.getString("property_locate2", "");
        if(!StringUtil.isBlank(property_locate2)){
            vo.setProperty_locate2(property_locate2);
        }
        //土地屬性
        String property_landapplication = sh.getString("property_landapplication", "");
        if(!StringUtil.isBlank(property_landapplication)){
            vo.setProperty_landapplication(property_landapplication);
        }
        String property_landattribute = sh.getString("property_landattribute", "");
        if(!StringUtil.isBlank(property_landattribute)){
            vo.setProperty_landattribute(property_landattribute);
        }

        //图片类型
        String propertyimg_sceimgtype = sh.getString("propertyimg_sceimgtype", "");
        if(!StringUtil.isBlank(propertyimg_sceimgtype)){
            String[] img = propertyimg_sceimgtype.split(",");
            vo.setPropertyimg_sceimgtype(img);
        }

        String propertyimg_path1 = sh.getString("propertyimg_path1", "");
        if(!StringUtil.isBlank(propertyimg_path1)){
            String[] img = propertyimg_path1.split(",");
            vo.setPropertyimg_path1(img);
        }


        String propertyimg_path2 = sh.getString("propertyimg_path2", "");
        if(!StringUtil.isBlank(propertyimg_path2)){
            String[] img = propertyimg_path2.split(",");
            vo.setPropertyimg_path2(img);
        }
        String propertyimg_path3 = sh.getString("propertyimg_path3", "");
        if(!StringUtil.isBlank(propertyimg_path3)){
            String[] img = propertyimg_path3.split(",");
            vo.setPropertyimg_path3(img);
        }
        String propertyimg_path4 = sh.getString("propertyimg_path4", "");
        if(!StringUtil.isBlank(propertyimg_path4)){
            String[] img = propertyimg_path4.split(",");
            vo.setPropertyimg_path4(img);
        }
        String propertyimg_path5 = sh.getString("propertyimg_path5", "");
        if(!StringUtil.isBlank(propertyimg_path5)){
            String[] img = propertyimg_path5.split(",");
            vo.setPropertyimg_path5(img);
        }
        String propertyimg_path6 = sh.getString("propertyimg_path6", "");
        if(!StringUtil.isBlank(propertyimg_path6)){
            String[] img = propertyimg_path6.split(",");
            vo.setPropertyimg_path6(img);
        }

        String propertyimg_path7 = sh.getString("propertyimg_path7", "");
        if(!StringUtil.isBlank(propertyimg_path7)){
            String[] img = propertyimg_path7.split(",");
            vo.setPropertyimg_path7(img);
        }
        String propertyimg_width = sh.getString("propertyimg_width", "");
        if(!StringUtil.isBlank(propertyimg_width)){
            String[] img = propertyimg_width.split(",");
            vo.setPropertyimg_width(img);
        }
        String propertyimg_height = sh.getString("propertyimg_height", "");
        if(!StringUtil.isBlank(propertyimg_height)){
            String[] img = propertyimg_height.split(",");
            vo.setPropertyimg_height(img);
        }
        String propertyimg_size = sh.getString("propertyimg_size", "");
        if(!StringUtil.isBlank(propertyimg_size)){
            String[] img = propertyimg_size.split(",");
            vo.setPropertyimg_size(img);
        }
        String propertyimg_name = sh.getString("propertyimg_name", "");
        if(!StringUtil.isBlank(propertyimg_name)){
            String[] img = propertyimg_name.split(",");
            vo.setPropertyimg_name(img);
        }

        return vo;
    }


    //身份信息
    public static void saveIdentify(Context context,IdentifyVO identify){
        Log.e("identifild_flag111()=",""+identify.getFlag()+identify.getChild_flag());
        SharedPreferences sh = Tools.getSharePreferences(context, identify.getFlag()+"identify"+identify.getChild_flag());

        SharedPreferences.Editor editor = saveIdentifyVO(sh,identify);

        editor.commit();
    }

    //身份信息
    public static IdentifyVO getIdentify(Context context,IdentifyVO identify){
        Log.e("identifild_flag()=",""+identify.getFlag()+identify.getChild_flag());
        SharedPreferences sh = Tools.getSharePreferences(context, identify.getFlag()+"identify"+identify.getChild_flag());
        IdentifyVO vo = getIdentifyVO(sh);
        return vo;
    }

    private static IdentifyVO getIdentifyVO(SharedPreferences sh) {
        IdentifyVO vo = new IdentifyVO();

        String flag = sh.getString("flag", "");
        if(!StringUtil.isBlank(flag)){
            vo.setFlag(Integer.parseInt(flag));
        }

       String child_flag= sh.getString("child_flag", "");
        if(!StringUtil.isBlank(child_flag)){
            vo.setChild_flag(Integer.parseInt(child_flag));
        }
        String account= sh.getString("account", "");
        vo.setAccount(account);
        String passwd= sh.getString("passwd", "");
        vo.setPasswd(passwd);
        String firstname= sh.getString("firstname", "");
        vo.setFirstname(firstname);
        String lastname= sh.getString("lastname", "");
        vo.setLastname(lastname);
        String email= sh.getString("email", "");
        vo.setEmail(email);
        String gender= sh.getString("gender", "");
        if(!StringUtil.isBlank(gender)){
            vo.setGender(Integer.parseInt(gender));
        }
        String addr= sh.getString("addr", "");
        vo.setAddr(addr);
        String name= sh.getString("name", "");
        vo.setName(name);
        String state= sh.getString("state", "");
        if(!StringUtil.isBlank(state)){
            vo.setState(Integer.parseInt(state));
        }

        String statename= sh.getString("statename", "");
        vo.setStatename(statename);
        String city= sh.getString("city", "");
        if(!StringUtil.isBlank(city)){
            vo.setCity(Integer.parseInt(city));
        }

        String cityname= sh.getString("cityname", "");
        vo.setCityname(cityname);
        String area= sh.getString("area", "");
        if(!StringUtil.isBlank(area)){
            vo.setArea(Integer.parseInt(area));
        }
        String areaname= sh.getString("areaname", "");
        vo.setAreaname(areaname);

        String street= sh.getString("street", "");
        if(!StringUtil.isBlank(street)){
            vo.setStreet(Integer.parseInt(street));
        }
        String streetname= sh.getString("streetname", "");
        vo.setStreetname(streetname);
        String wstreet= sh.getString("wstreet", "");
        vo.setWstreet(wstreet);
        String wstreetname= sh.getString("wstreetname", "");
        vo.setWstreetname(wstreetname);
        String alley= sh.getString("alley", "");
        vo.setAlley(alley);
        String gate= sh.getString("gate", "");
        vo.setGate(gate);
        String floor= sh.getString("floor", "");
        vo.setFloor(floor);
        String room= sh.getString("room", "");
        vo.setRoom(room);

        String community_seq= sh.getString("community_seq", "");
        if(!StringUtil.isBlank(community_seq)){
            vo.setCommunity_seq(Integer.parseInt(community_seq));
        }

        String communityname= sh.getString("communityname", "");
        vo.setCommunityname(communityname);
        String comstate= sh.getString("comstate", "");
        if(!StringUtil.isBlank(comstate)){
            vo.setComstate(Integer.parseInt(comstate));
        }
        String comcity= sh.getString("comcity", "");
        if(!StringUtil.isBlank(comcity)){
            vo.setComcity(Integer.parseInt(comcity));
        }
        String comarea= sh.getString("comarea", "");
        if(!StringUtil.isBlank(comarea)){
            vo.setComarea(Integer.parseInt(comarea));
        }

        String companyaddr= sh.getString("companyaddr", "");
        vo.setCompanyaddr(companyaddr);
        String wcompanystreet= sh.getString("wcompanystreet", "");
        vo.setWcompanystreet(wcompanystreet);
        String com_alley= sh.getString("com_alley", "");
        vo.setCom_alley(com_alley);
        String com_gate= sh.getString("com_gate", "");
        vo.setCom_gate(com_gate);
        String com_floor= sh.getString("com_floor", "");
        vo.setCom_floor(com_floor);
        String com_room= sh.getString("com_room", "");
        vo.setCom_room(com_room);
        String companycommunity_seq= sh.getString("companycommunity_seq", "");
        if(!StringUtil.isBlank(companycommunity_seq)){
            vo.setCompanycommunity_seq(Integer.parseInt(companycommunity_seq));
        }

        String companycommunityname= sh.getString("companycommunityname", "");
        vo.setCompanycommunityname(companycommunityname);
        String brand= sh.getString("brand", "");
        vo.setBrand(brand);
        String brandname= sh.getString("brandname", "");
        vo.setBrandname(brandname);

        String companyname= sh.getString("companyname", "");
        vo.setCompanyname(companyname);

        String uniquecode= sh.getString("uniquecode", "");
        vo.setUniquecode(uniquecode);

        String shopname= sh.getString("shopname", "");
        vo.setShopname(shopname);
        String shoptype= sh.getString("shoptype", "");
        if(!StringUtil.isBlank(shoptype)){
            vo.setShoptype(Integer.parseInt(shoptype));
        }

        String brokerage= sh.getString("brokerage", "");
        vo.setBrokerage(brokerage);

        String server_addr1= sh.getString("server_addr1", "");
        if(!StringUtil.isBlank(server_addr1)){
            vo.setServer_addr1(Integer.parseInt(server_addr1));
        }
        String server_addr2= sh.getString("server_addr2", "");
        if(!StringUtil.isBlank(server_addr2)){
            vo.setServer_addr2(Integer.parseInt(server_addr2));
        }


        String certi1= sh.getString("certi1", "");
        vo.setCerti1(certi1);

        String certi2= sh.getString("certi2", "");
        vo.setCerti2(certi2);

        String certi3= sh.getString("certi3", "");
        vo.setCerti3(certi3);
        String idnum= sh.getString("idnum", "");
        vo.setIdnum(idnum);

        String isservepres= sh.getString("isservepres", "");
        if(!StringUtil.isBlank(isservepres)){
            vo.setIsservepres(Integer.parseInt(isservepres));
        }
        String titles= sh.getString("titles", "");
        if(!StringUtil.isBlank(titles)){
            vo.setTitles(Integer.parseInt(titles));
        }

        String contactphone= sh.getString("contactphone", "");
        vo.setContactphone(contactphone);

        String companyphone= sh.getString("companyphone", "");
        vo.setCompanyphone(companyphone);

        return vo;
    }

    private static SharedPreferences.Editor saveIdentifyVO(SharedPreferences sh,IdentifyVO identify) {
        SharedPreferences.Editor editor = sh.edit();
        editor.putString("flag", ""+identify.getFlag());
        editor.putString("child_flag", ""+identify.getChild_flag());
        editor.putString("account", ""+identify.getAccount());
        editor.putString("passwd", ""+identify.getPasswd());
        editor.putString("firstname", ""+identify.getFirstname());
        editor.putString("lastname", ""+identify.getLastname());
        editor.putString("email", ""+identify.getEmail());
        editor.putString("gender", ""+identify.getGender());
        editor.putString("addr", ""+identify.getAddr());
        editor.putString("name", ""+identify.getName());
        editor.putString("state", ""+identify.getState());
        editor.putString("statename", ""+identify.getStatename());
        editor.putString("city", ""+identify.getCity());
        editor.putString("cityname", ""+identify.getCityname());
        editor.putString("area", ""+identify.getArea());
        editor.putString("areaname", ""+identify.getAreaname());
        editor.putString("street", ""+identify.getStreet());
        editor.putString("streetname", ""+identify.getStreetname());
        editor.putString("wstreet", ""+identify.getWstreet());
        editor.putString("wstreetname", ""+identify.getWstreetname());
        editor.putString("alley", ""+identify.getAlley());
        editor.putString("gate", ""+identify.getGate());
        editor.putString("floor", ""+identify.getFloor());
        editor.putString("room", ""+identify.getRoom());
        editor.putString("community_seq", ""+identify.getCommunity_seq());
        editor.putString("communityname", ""+identify.getCommunityname());
        editor.putString("comcity", ""+identify.getComcity());
        editor.putString("comarea", ""+identify.getComarea());
        editor.putString("companyaddr", ""+identify.getCompanyaddr());
        editor.putString("wcompanystreet", ""+identify.getWcompanystreet());
        editor.putString("com_alley", ""+identify.getCom_alley());
        editor.putString("com_gate", ""+identify.getCom_gate());
        editor.putString("com_floor", ""+identify.getCom_floor());
        editor.putString("com_room", ""+identify.getCom_room());
        editor.putString("companycommunity_seq", ""+identify.getCompanycommunity_seq());
        editor.putString("companycommunityname", ""+identify.getCompanycommunityname());
        editor.putString("brand", ""+identify.getBrand());
        editor.putString("brandname", ""+identify.getBrandname());
        editor.putString("companyname", ""+identify.getCompanyname());
        editor.putString("uniquecode", ""+identify.getUniquecode());
        editor.putString("shopname", ""+identify.getShopname());
        editor.putString("brokerage", ""+identify.getBrokerage());
        editor.putString("server_addr1", ""+identify.getServer_addr1());
        editor.putString("server_addr2", ""+identify.getServer_addr2());
        editor.putString("certi1", ""+identify.getCerti1());
        editor.putString("certi2", ""+identify.getCerti2());
        editor.putString("certi3", ""+identify.getCerti3());
        editor.putString("idnum", ""+identify.getIdnum());
        editor.putString("isservepres", ""+identify.getIsservepres());
        editor.putString("titles", ""+identify.getTitles());
        editor.putString("contactphone", ""+identify.getContactphone());
        editor.putString("companyphone", ""+identify.getCompanyphone());



        return editor;
    }





}
